package com.detection.dahua.demo.accesscontrol.application;

import com.google.zxing.WriterException;
import com.detection.dahua.util.QRCodeUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.io.IOException;

/**
 * program:java-sdk-demo
 *
 * @Author: 355079
 * @Date:2024-04-01 17:19
 * @Description:
 */
@Slf4j
public class ApplicationDemoTest {
    private ApplicationDemo applicationDemo;

    public ApplicationDemoTest() {
        applicationDemo = new ApplicationDemo();
    }

    /**
     * 测试获取业主二维码字符串并生成二维码图片
     */
    @Test
    public void testGenerateQRCode(){
        String personCode = "244031";
        String QRCode = applicationDemo.generateQRCode(personCode);
        //根据二维码字符串生成二维码图片
        if(QRCode!=null) {
            try {
                QRCodeUtil.generateQRCode(QRCode,300,300,"jpg","D://test1.jpg");
            } catch (IOException e) {
                e.printStackTrace();
                log.error(e.getMessage(),e);
            } catch (WriterException e) {
                e.printStackTrace();
                log.error(e.getMessage(),e);
            }
        }
    }

}
